/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.support;

import java.util.concurrent.TimeUnit;

import com.yanlight.Constants;

import okhttp3.OkHttpClient;

/**
 * 
 * @author haolw
 * @time 2017/09/21
 */
public abstract class OkHttpFactory {
	private static OkHttpClient client = newClient();

	public static OkHttpClient getClient() {
		return client;
	}

	public static OkHttpClient newClient() {
		okhttp3.OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
		builder.connectTimeout(Constants.DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS);
		builder.readTimeout(Constants.DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
		builder.writeTimeout(Constants.DEFAULT_WRITE_TIMEOUT, TimeUnit.SECONDS);
		return builder.build();
	}

}
